package com.hq.ims.data.service;

import com.hq.ims.data.dao.BusInfoNotificationMapper;
import com.hq.ims.data.entity.BusInfoNotification;
import com.hq.ims.data.entityenum.EnumReceiveStatus;
import com.hq.ims.data.vo.BusInfoNotificationMapstruct;
import com.hq.mybatis.base.BaseService;
import com.hq.mybatis.base.page.RequestPage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 蒋柏平
 * @detail 经营信息推送表 服务实现类
 * @since 20241024
 */
@Service
public class BaseBusInfoNotificationService extends BaseService<BusInfoNotificationMapper, BusInfoNotification> {

    @Resource
    private BusInfoNotificationMapper busInfoNotificationMapper;

    /**
     * 经营信息接收-列表查询
     *
     * @param page     分页对象
     * @param searchVo 条件搜索对象
     */
    public void getByPage(RequestPage<BusInfoNotificationMapstruct.BusInfoNotificationVo> page,
                          BusInfoNotificationMapstruct.PageSearchVo searchVo) {
        busInfoNotificationMapper.pageList(page, searchVo);
    }

    /**
     * 经营信息接收-详情
     */
    public BusInfoNotificationMapstruct.DetailVo getDetailVo(String busInfoNotificationId) {
        BusInfoNotification busInfoNotification = this.getById(busInfoNotificationId);
        // 未接收/已拒收情况下只能查看项目基本信息
        if (EnumReceiveStatus.UnReceive.equals(busInfoNotification.getReceiveStatus()) ||
                EnumReceiveStatus.Rejection.equals(busInfoNotification.getReceiveStatus())) {
            return busInfoNotificationMapper.getBasicInfoDetailVo(busInfoNotificationId);
        } else {
            return busInfoNotificationMapper.getDetailVo(busInfoNotificationId);
        }
    }
}